package com.zpark.se.thread;

/**
 * @PackageName: com.zpark.se.thread
 * @ClassName: Demo13
 * @Description:
 * @author: RZS
 * @date: 2024/12/2  8:53
 */
public class Demo13 {
    public static void main(String[] args) {
        // 创建栈操作类对象
        StackDemo01 sd = new StackDemo01();
        // 创建线程
        Thread t1 = new Thread(() -> {
            for (int i = 0; i < 10; i++) {
                // 元素入栈
                sd.push("大锤" + i);
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        });

        Thread t2 = new Thread(() -> {
            for (int i = 0; i < 10; i++) {
                // 元素出栈
                sd.pop();
            }
        });

        // 启动线程
        t1.start();
        t2.start();
    }
}
